package com.wanmait.houlang.controller;


import com.wanmait.houlang.pojo.*;
import com.wanmait.houlang.service.BorderlineService;
import com.wanmait.houlang.service.EnrollmentScheduleService;
import com.wanmait.houlang.service.GradeTypeService;
import com.wanmait.houlang.service.YearService;
import com.wanmait.houlang.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/webContent")
public class BorderlineController {
    @Resource
    private YearService yearService;
    @Resource
    private GradeTypeService gradeTypeService;
    @Resource
    private BorderlineService borderlineService;
    @Resource
    private EnrollmentScheduleService enrollmentScheduleService;

    //省分数线和招生计划：年份下拉列表框
    @GetMapping("year")
    public Result findAllYear(){
        List<AdmissionsYear> admissionsYear=yearService.findAll();
        return Result.success(admissionsYear);
    }
    //省分数线和招生计划：通过年份查分数类型下拉列表框
    @GetMapping("gradeType")
    public Result findByYear(Integer yid){
        List<GradeType> gradeTypes=gradeTypeService.findByYear(yid);
        return Result.success(gradeTypes);
    }
    //招生计划：通过年份、分数类型查-----录取批次-----下拉列表框
    @GetMapping("admissionsBatch")
    public Result findAdmissionsBatch(Integer yid,Integer gtid){
        List<AdmissionsBatch> admissionsBatches = enrollmentScheduleService.findAllAdmissionsBatch(yid,gtid);
        return Result.success(admissionsBatches);
    }
    //通过下拉列表框多条件查询省分数线
    @GetMapping("borderline")
    public Result findBorderline(Integer yid, Integer gid, Integer sid){
        List<Borderline> borderlines=borderlineService.findBorderline(yid, gid, sid);
        return Result.success(borderlines);
    }

    //学校招生数据：招生计划
    @GetMapping("/enrollmentData/{id:\\d+}")
    public Result enrollmentData(@PathVariable("id") Integer schoolId){
        List<EnrollmentSchedule> enrollmentSchedules = enrollmentScheduleService.findESBySchoolId(schoolId);
        return Result.success(enrollmentSchedules);
    }

    //通过条件查招生计划
    @GetMapping("/enrollmentData")
    public Result enrollmentData(DTO dto){
        List<EnrollmentSchedule> enrollmentSchedules = enrollmentScheduleService.findByCondition(dto);
        return Result.success(enrollmentSchedules);
    }
}
